home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 1.toast / pc / sample code / graphics 3d / rave 1.5 devkit / empty engine / empty engine code / tttinseltown.h < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  8.6 KB  |  240 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        TtTinselTown.h                                             **
  4.  **                                                                          **
  5.  **     Purpose:     Sample empty drawing engine.                             **
  6.  **                 Include file.                                             **
  7.  **                                                                          **
  8.  **     Author:        Mike W. Kelley                                             **
  9.  **                                                                          **
  10.  **                    2/3/95    Revised for 0.9 SDK release                         **
  11.  **                                                                          **
  12.  **     Copyright (C) 1994-95 Apple Computer, Inc.  All rights reserved.     **
  13.  **     Apple Computer Confidential                                             **
  14.  **                                                                          **
  15.  *****************************************************************************/
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21. /************************************************************************************************
  22.  * Miscellaneous constants.
  23.  ***********************************************************************************************/
  24.  
  25. #define kTtMaxTag        kQATag_Texture
  26.  
  27. #define kTtFalse        0
  28. #define kTtTtue            1
  29.  
  30. #define kTtMyVendorID    (-1)    /* NEED TO GET THIS FROM APPLE! */
  31. #define kTtMyEngineID    0        /* Whatever I choose */
  32. #define kTtMyRevisionID    0        /* Whatever I choose */
  33.  
  34. /************************************************************************************************
  35.  * The TQADrawPrivate datatypes.
  36.  ***********************************************************************************************/
  37.  
  38. typedef union TTtState
  39. {
  40.     unsigned long        i;
  41.     float                f;
  42.     const void             *p;
  43. } TTtState;
  44.  
  45. typedef struct TTtDrawPrivate
  46. {
  47.     /*
  48.      * Storage for state variables. All drawing engines need this
  49.      * in some form.
  50.      */
  51.     
  52.     TTtState            state [kTtMaxTag + 1];    /* State variables */
  53.     
  54.     /*
  55.      * Various private draw engine data. Here we've kept a copy of
  56.      * the TQADevice passed to QADrawContextNew(), the creation flags,
  57.      * and some data that describes the target region of the device.
  58.      */
  59.     
  60.     long            flags;                    /* Creation flags */
  61.     TQADevice        device;                    /* Creation device */
  62.     TQARect            deviceRect;                /* Target rect position */
  63.  
  64.     long            width;
  65.     long            height;
  66.     long            rowBytes;
  67.     long            depth;
  68.     void            *baseAddr;
  69. } TTtDrawPrivate;
  70.  
  71. /************************************************************************************************
  72.  * The TQAStorePrivate datatypes. This is just a placeholder; these are
  73.  * engine-specific. A single TTtStorePrivate global instance is used to hold
  74.  * information on all bitmaps and textures allocated by the engine.
  75.  ***********************************************************************************************/
  76.  
  77. typedef struct TTtBitmap TTtBitmap;
  78. typedef struct TTtTexture TTtTexture;
  79. typedef struct TTtStorePrivate TTtStorePrivate;
  80.  
  81. struct TTtStorePrivate
  82. {
  83.     TTtBitmap            *firstBitmap;        /* Head of linked list */
  84.     TTtTexture            *firstTextureMap;    /* Head of linked list */
  85. };
  86.  
  87. extern TTtStorePrivate    gTtStorePrivate;
  88.  
  89. /************************************************************************************************
  90.  * Utility function prototypes.
  91.  ***********************************************************************************************/
  92.  
  93. #ifdef kTtDebug
  94.     void TtError (
  95.         const char        *message);
  96. #endif
  97.  
  98. #define TtMemoryNew(nBytes)        malloc(nBytes)
  99. #define TtMemoryDelete(target)    free(target)
  100.  
  101. /************************************************************************************************
  102.  * TtRegister() causes MAB to register itself with Tinsel Town. When we're linking
  103.  * our engine directly, this should be called before any Tinsel Town calls are made.
  104.  * When we're building as a shared library, this should be called as the library
  105.  * initialization function. Because the initialization function must return an
  106.  * OSErr, that function does so.
  107.  ***********************************************************************************************/
  108.  
  109. OSErr TtRegister (void);
  110.  
  111. /************************************************************************************************
  112.  * Tinsel Town system methods.
  113.  ***********************************************************************************************/
  114.  
  115. TQAError TtDrawPrivateNew (
  116.     TQADrawContext        *newDrawContext,    /* Draw context to initialize */
  117.     const TQADevice        *device,            /* Target device */
  118.     const TQARect        *rect,                /* Target rectangle (device coordinates) */
  119.     const TQAClip        *clip,                /* 2D clip region (or NULL) */
  120.     unsigned long        flags);                /* Mask of kQAContext_xxx */
  121.  
  122. void TtDrawPrivateDelete (
  123.     TQADrawPrivate        *drawPrivate);        /* Private context data to delete */
  124.  
  125. TQAError TtEngineDeviceCheck (
  126.     const TQADevice    *device);                /* Target device */
  127.  
  128. TQAError TtEngineGestalt (
  129.     TQAGestaltSelector    selector,            /* Gestalt parameter being requested */
  130.     void                *response);            /* Buffer that receives response */
  131.  
  132. /************************************************************************************************
  133.  * Tinsel Town draw context methods.
  134.  ***********************************************************************************************/
  135.  
  136. void TtSetFloat (
  137.     TQADrawContext            *drawContext,        /* Draw context */
  138.     TQATagFloat                tag,                /* Tag of variable to set */
  139.     float                    newValue);            /* New value for variable */
  140.  
  141. void TtSetInt (
  142.     TQADrawContext            *drawContext,        /* Draw context */
  143.     TQATagInt                tag,                /* Tag of variable to set */
  144.     unsigned long            newValue);            /* New value for variable */
  145.  
  146. void TtSetPtr (
  147.     TQADrawContext            *drawContext,        /* Draw context */
  148.     TQATagPtr                tag,                /* Tag of variable to set */
  149.     const void                *newValue);            /* New value for variable */
  150.  
  151. float TtGetFloat (
  152.     const TQADrawContext    *drawContext,        /* Draw context */
  153.     TQATagFloat                tag);                /* Tag of variable to get */
  154.  
  155. unsigned long TtGetInt (
  156.     const TQADrawContext    *drawContext,        /* Draw context */
  157.     TQATagInt                tag);                /* Tag of variable to get */
  158.  
  159. void *TtGetPtr (
  160.     const TQADrawContext    *drawContext,        /* Draw context */
  161.     TQATagPtr                tag);                /* Tag of variable to get */
  162.  
  163. void TtDrawPoint (
  164.     const TQADrawContext    *drawContext,        /* Draw context */
  165.     const TQAVGouraud         *v0);                /* Vertex */
  166.  
  167. void TtDrawLine (
  168.     const TQADrawContext    *drawContext,        /* Draw context */
  169.     const TQAVGouraud         *v0,                /* Vertex 0 */
  170.     const TQAVGouraud     *v1);                /* Vertex 1 */
  171.  
  172. void TtDrawTriGouraud (
  173.     const TQADrawContext    *drawContext,        /* Draw context */
  174.     const TQAVGouraud     *v0,                /* Vertex 0 */
  175.     const TQAVGouraud     *v1,                /* Vertex 1 */
  176.     const TQAVGouraud     *v2,                /* Vertex 2 */
  177.     unsigned long        flags);                /* Mask of kQATriFlags_xxx flags */
  178.  
  179. void TtDrawTriTexture (
  180.     const TQADrawContext    *drawContext,        /* Draw context */
  181.     const TQAVTexture     *v0,                /* Vertex 0 */
  182.     const TQAVTexture     *v1,                /* Vertex 1 */
  183.     const TQAVTexture     *v2,                /* Vertex 2 */
  184.     unsigned long        flags);                /* Mask of kQATriFlags_xxx flags */
  185.  
  186. void TtDrawBitmap (
  187.     const TQADrawContext    *drawContext,        /* Draw context */
  188.     const TQAVGouraud     *v,                    /* xyz, and (if a 1 bit/pixel bitmap) argb */
  189.     TQABitmap            *bitmap);            /* Previously allocated by QABitmapNew() */
  190.  
  191. void TtRenderStart (
  192.     const TQADrawContext    *drawContext,        /* Draw context */
  193.     const TQARect        *dirtyRect,            /* Minimum area to clear; NULL means whole buffer */
  194.     const TQADrawContext    *initialContext);    /* Initial background image (or NULL) */
  195.  
  196. TQAError TtRenderEnd (
  197.     const TQADrawContext    *drawContext,        /* Draw context */
  198.     const TQARect        *modifiedRect);        /* Minimum area to swap; NULL means whole buffer */
  199.  
  200. TQAError TtRenderAbort (
  201.     const TQADrawContext    *drawContext);        /* Draw context */
  202.  
  203. TQAError TtSync (
  204.     const TQADrawContext    *drawContext);        /* Draw context */
  205.  
  206. TQAError TtFlush (
  207.     const TQADrawContext    *drawContext);        /* Draw context */
  208.  
  209. /************************************************************************************************
  210.  * Tinsel Town store context methods.
  211.  ***********************************************************************************************/
  212.  
  213. TQAError TtTextureNew (
  214.     unsigned long        flags,                /* Mask of kQATexture_xxx flags */
  215.     TQAImagePixelType    pixelType,            /* Depth, color space, etc. */
  216.     const TQAImage        images[],            /* Image(s) for texture */
  217.     TQATexture            **newTexture);        /* (Out) Newly created TQATexture, or NULL on error */ 
  218.  
  219. TQAError TtTextureDetach (
  220.     TQATexture            *texture);            /* Previously allocated by QATextureNew() */
  221.  
  222. void TtTextureDelete (
  223.     TQATexture            *texture);            /* Previously allocated by QATextureNew() */
  224.  
  225. TQAError TtBitmapNew (
  226.     unsigned long        flags,                /* Mask of kQABitmap_xxx flags */
  227.     TQAImagePixelType    pixelType,            /* Depth, color space, etc. */
  228.     const TQAImage        *image,                /* Image */
  229.     TQABitmap            **newBitmap);        /* (Out) Newly created TQABitmap, or NULL on error */ 
  230.  
  231. TQAError TtBitmapDetach (
  232.     TQABitmap            *bitmap);            /* Previously allocated by QABitmapNew() */
  233.  
  234. void TtBitmapDelete (
  235.     TQABitmap            *bitmap);            /* Previously allocated by QABitmapNew() */
  236.  
  237. #ifdef __cplusplus
  238. };
  239. #endif
  240.